package com.xmfh.wemedia.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xmfh.wemedia.model.DdMicro;
import com.xmfh.wemedia.model.DdUserBaseMicro;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 微头条表 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2022-04-03
 */
@Mapper
public interface DdMicroMapper extends BaseMapper<DdMicro> {
    // @Insert("insert into dd_micro values(null, #{content}, #{hasImage}, #{fabulous}, #{comment}, #{views}, #{hot}, #{userId}, #{createTime})")
    // 返回MySQL数据库自动生成的id值，并且保存到micro中
    // @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertDynamic(DdMicro micro);

    //    @Select("select * from dd_micro where user_id=#{userId} limit #{pageNum},#{pageSize}")
    List<DdMicro> getByUserID(@Param("pageNum") Integer pageNum,
                              @Param("pageSize") Integer pageSize, @Param("userId") Integer userId);

    //    @Select("select count(1) from dd_micro where user_id=#{userId}")
    int selectCount(Integer userId);

    /**
     * 获取个人主页中微头条分页的内容
     *
     * @param id 目前登陆用户的ID
     * @return 个人微头条的集合
     */
    List<DdUserBaseMicro> getPersonalMicroById(Integer id);
}
